#ifndef RANDOM_STUDENTS_H
#define RANDOM_STUDENTS_H
#include "global.h"
#include "speaker.h"
class RandomStudent : public QMainWindow
{
	Q_OBJECT
public:
	RandomStudent(QWidget *parent = nullptr);
	~RandomStudent();
private:
	QPushButton *startRandomButton, *historyButton, *speakButton;
	QTimer *timer = new QTimer(this), *chose = new QTimer(this);
	QSpinBox *spinBox;
	QSlider *horizontalSlider;
	QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
	QString selectedStudentsText = "";
	QString *studentNames = nullptr;
	QDialog *historyDialog = nullptr;
#ifdef WIN32
	Speaker *m_speaker;
	HHOOK keyboardHook;
	DWORD lastVolUpTime = 0;
	static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
#endif
	int NUM, currentStudentIndex = 0, selectedCount = 0, count = 1;
	char *studentIdQueue = nullptr;
	char studentCount = 127;
	void createUI();
	void RandomlyScrambled(char begin = 0, char end = -1)
	{
		if (end == -1) end = studentCount;
		char R, temp;
		for (int u = begin; u < end; u++) {
			R = QRandomGenerator::global()->bounded(begin, end);
			temp = studentIdQueue[u];
			studentIdQueue[u] = studentIdQueue[R];
			studentIdQueue[R] = temp;
		}
	}
private slots:
	void onStudentListChanged();
	void on_spinBox_valueChanged(int arg1);
	void on_horizontalSlider_valueChanged(int value);
	void on_historyButton_clicked();
	void on_startRandomButton_clicked();
	void on_speak_clicked();
public slots:
	void selectNextStudent();
	void showStudents();
};
#endif
